package com.freestyle.nettychat.chat.config;

import com.freestyle.nettychat.chat.service.ChatService;
import com.freestyle.nettychat.chat.service.RedisChatServiceFactory;
import com.freestyle.redis.expire.RedisExpirationTemplate;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Created by rocklee on 2022/2/5 11:40
 */
@Configuration
@ConfigurationProperties("chat-config")
@Data
public class ChatConfig {
  private int port;

  @Resource
  private RedisExpirationTemplate<String,Object> redisExpirationTemplate;
  @Bean
  public ChatService chatService(){
    return  new RedisChatServiceFactory(redisExpirationTemplate).buildChatService();
  }
}
